package com.demo.service.impl;

import com.demo.pojo.User;
import com.demo.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author Windy
 * @Date 2022/9/16 10:20
 * @Version 1.0
 **/
@Service
public class UserServiceImpl implements UserService {

    @Override
    public boolean login(User user) {
        UsernamePasswordToken token = new UsernamePasswordToken(user.getName(), user.getPwd());

        Subject subject = SecurityUtils.getSubject();

        subject.login(token);

        if (subject.isAuthenticated()){
            return true;
        }

        return false;
    }
}
